package com.platform.qujia.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.gson.Gson;
import com.platform.qujia.pojo.IntegralOrder;
import com.platform.qujia.pojo.PointsMerchandiseWriteOffRecord;
import com.platform.qujia.pojo.vo.IntegralOrderVo;
import com.platform.qujia.service.PointsMerchandiseWriteOffRecordService;
import com.platform.qujia.dao.PointsMerchandiseWriteOffRecordMapper;
import com.platform.qujia.utils.ResultData;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author PC
 * @description 针对表【points_merchandise_write_off_record(积分商品核销记录表)】的数据库操作Service实现
 * @createDate 2023-11-02 10:46:32
 */
@Service
public class PointsMerchandiseWriteOffRecordServiceImpl extends ServiceImpl<PointsMerchandiseWriteOffRecordMapper, PointsMerchandiseWriteOffRecord>
        implements PointsMerchandiseWriteOffRecordService {

    @Resource
    private PointsMerchandiseWriteOffRecordMapper offRecordMapper;

    @Override
    public String getIntegralOrderByOrderId(String mobilePhone, String integralOrderNo) {
        Gson gson = new Gson();
        //返回结果集
        ResultData resultData = null;
        IntegralOrder integralOrder = IntegralOrder.builder().integralOrderNo(integralOrderNo).mobilePhone(mobilePhone).build();
        IntegralOrderVo integralOrderByOrderId = offRecordMapper.getIntegralOrderByOrderId(integralOrder);
        if (ObjectUtils.isNotEmpty(integralOrderByOrderId)) {

            resultData = ResultData.success(integralOrderByOrderId);

        } else {
            resultData = ResultData.error("没有获取到核销信息");
        }
        return gson.toJson(resultData);
    }
}




